

#region Using Directives
using System;
using System.Runtime.InteropServices;
using System.Text;
#endregion

namespace Hoo.Windows.Shell.Util {  

    public class Win32Helpers {


        [DllImport("kernel32.dll")]
        internal static extern void SetLastError(uint errorCode);

        /// <summary>
        /// Converts an item identifier list to a file system path. (Note: SHGetPathFromIDList calls the ANSI version, must call SHGetPathFromIDListW for .NET)
        /// </summary>
        /// <param name="pidl">Address of an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop).</param>
        /// <param name="pszPath">Address of a buffer to receive the file system path. This buffer must be at least MAX_PATH characters in size.</param>
        /// <returns>Returns TRUE if successful, or FALSE otherwise. </returns>
        [DllImport("shell32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool SHGetPathFromIDListW(IntPtr pidl, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszPath);


        [DllImport("shell32")]
        internal static extern uint DragQueryFile(uint hDrop, uint iFile, StringBuilder buffer, int cch);

        [DllImport("user32", SetLastError = true)]
        internal static extern uint CreatePopupMenu();

        [DllImport("user32", SetLastError = true)]
        internal static extern int InsertMenuItem(uint hmenu, uint uposition, bool fByPosition, ref MENUITEMINFO mii);

        [DllImport("user32.dll", SetLastError = true)]
        static extern bool AppendMenu(uint hMenu, uint uFlags, uint uIDNewItem, string lpNewItem);

        [DllImport("user32.dll")]
        public static extern int GetMenuItemID(uint hMenu, uint nPosition);

        [DllImport("user32")]
        public static extern int GetMenuItemInfo(uint hMenu, uint uposition, bool fByPosition, ref MENUITEMINFO lpMenuItemInfo);

        [DllImport("user32")]
        public static extern int GetMenuInfo(uint hMenu, out MENUINFO lpMenuInfo);

        [DllImport("user32.dll",SetLastError=true)]
        public static extern int SetMenuItemBitmaps(uint hMenu, uint nPosition, uint uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);

    }
}
